package com.situ.blog.service.impl;


import com.situ.blog.dao.IUserDao;
import com.situ.blog.dao.impl.UserDaoImpl;
import com.situ.blog.pojo.entity.User;
import com.situ.blog.service.IUserService;

public class UserServiceImpl implements IUserService {
    private IUserDao userDao = new UserDaoImpl();
//    @Override
//    public PageInfo selectByPage(Integer pageNo, Integer pageSize) {
//        int offset = (pageNo - 1) * pageSize;
//        List<User> list = userDao.selectByPage(offset, pageSize);
//        int totalCount = userDao.selectTotalCount();
//        int totalPage = (int) Math.ceil((double) totalCount / pageSize);
//        PageInfo<User> pageInfo = new PageInfo<User>(list, totalPage, pageNo, pageSize);
//        return pageInfo;
//    }

    @Override
    public User login(String username, String password) {
        return userDao.login(username, password);
    }

    @Override
    public void add(User user) {
        userDao.add(user);
    }

    @Override
    public void register(User user) {
        userDao.add(user);
    }

    @Override
    public void deleteById(Integer id) {
        userDao.deleteById(id);
    }

    @Override
    public User selectById(Integer id) {
        return userDao.selectById(id);
    }

    @Override
    public void update(User user) {
        userDao.update(user);
    }
}
